-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support use alias in dynamic import #7485
Conversation
The PR just resolve After looking at the source code of
export function resolveBuildPlugins(config: ResolvedConfig): {
pre: Plugin[]
post: Plugin[]
} {
const options = config.build
return {
pre: [
watchPackageDataPlugin(config),
buildHtmlPlugin(config),
commonjsPlugin(options.commonjsOptions),
dataURIPlugin(),
// 🚨 We may need to deal with alias before here
// `@rollup/plugin-dynamic-import-vars`
dynamicImportVars(options.dynamicImportVarsOptions),
assetImportMetaUrlPlugin(config),
...(options.rollupOptions.plugins
? (options.rollupOptions.plugins.filter(Boolean) as Plugin[])
: [])
],
post: [
buildImportAnalysisPlugin(config),
buildEsbuildPlugin(config),
...(options.minify ? [terserPlugin(config)] : []),
...(options.manifest ? [manifestPlugin(config)] : []),
...(options.ssrManifest ? [ssrManifestPlugin(config)] : []),
buildReporterPlugin(config),
loadFallbackPlugin()
]
}
} |
Not sure my idea is correct, I tried to write a plugin compatible with the use of alias. |
@patak-dev Hey! 👋 I hope vite can support custom plugins sorting. For example, some plugins must run after the specified plugins. import { defineNuxtConfig } from 'nuxt3';
import dynamicImport from 'vite-plugin-dynamic-import';
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
vite: {
plugins: [
dynamicImport(),
],
},
}); I tried to reorder the plugins inside the plugin, but it didn't work! {
name: 'vite-plugin-dynamic-import',
config(_config) {
// Move "vite-plugin-dynamic-import" after "@vitejs/plugin-vue"
// But it doesn't work
_config.plugins = sortPlugin(_config.plugins);
return _config;
},
} This may be changed through the {
name: 'vite-plugin-dynamic-import',
configResolved(_config) {
_config.plugins.splice(targetIndex, 0, plugin);
},
} |
repeat with #7756 |
Description
The PR improved from #7339
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).